<?php
/**
 * Agencia Active Record
 * @author  <your-name-here>
 */
class Agencia extends TRecord
{
    const TABLENAME = 'agencia';
    const PRIMARYKEY= 'id_agencia';
    const IDPOLICY =  'max'; // {max, serial}
    
    
    private $banco;

    /**
     * Constructor method
     */
    public function __construct($id = NULL, $callObjectLoad = TRUE)
    {
        parent::__construct($id, $callObjectLoad);
        parent::addAttribute('id_banco');
        parent::addAttribute('nome');
        parent::addAttribute('cod_cidade');
        parent::addAttribute('digito');
    }

    
    /**
     * Method set_banco
     * Sample of usage: $agencia->banco = $object;
     * @param $object Instance of Banco
     */
    public function set_banco(Banco $object)
    {
        $this->banco = $object;
        $this->banco_id = $object->id;
    }
    
    /**
     * Method get_banco
     * Sample of usage: $agencia->banco->attribute;
     * @returns Banco instance
     */
    public function get_banco()
    {
        // loads the associated object
        if (empty($this->banco))
            $this->banco = new Banco($this->banco_id);
    
        // returns the associated object
        return $this->banco;
    }
    


}
